<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use common\models\User;
use common\models\TestItems;
use common\models\TestStandard;
use backend\assets\AppAsset;
use yii\captcha\Captcha;

/* @var $this yii\web\View */
/* @var $model common\models\User */

$this->title = $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Users', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-view">

    <h1><?= Html::encode($this->title) ?></h1>
<button type='button' class='btn btn-primary' data-toggle='modal' data-target='#add_info'>更新</button>
    <!-- <p>
        <?= Html::a('更改', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
        <?= Html::a('删除', ['delete', 'id' => $model->id], [
            'class' => 'btn btn-danger',
            'data' => [
                'confirm' => '确定注销此号？',
                'method' => 'post',
            ],
        ]) ?>
    </p> -->

    <?= DetailView::widget([
        'model' => $model,
        'attributes' => [
            'id',
            'username',
            'phone',
            'email:email',
            'real_name',
            'third_user_id',
            [
                'attribute'=> 'status',
                'value' => User::itemAlias("status", $model->status),
            ],
            'available_money',
            'create_time',
            'reigster_ip',
            'last_login_time',
            'last_login_ip',
        ],
    ]) ?>
 <!--修改密码-->

    <div class="modal fade" id="add_info" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">修改密码</h4>
            </div>
            <div class="modal-body">
           
                <table class="table table-bordered">
                    <tr>
                        <td align="center">新密码：</td>
                        <td align="center"><input user_id="<?= $model->id?>" type="password" id="password" value="" required/></td>
                    </tr>
                    <tr>
                        <td align="center">请再次输入新密码：</td>
                        <td align="center"><span data-toggle="tooltip" data-placement="bottom">
                                <input type="password" id="newpassword" value="" required/></span></td>
                    </tr>
                    <tr>
                        <td align="center">邮箱：</td>
                        <td align="center"><span data-toggle="tooltip" data-placement="bottom">
                                <input type="email" id="email" value="<?=$model->email ?>" required/></span></td>
                    </tr>
                    <tr>
                        <td align="center">真实姓名：</td>
                        <td align="center"><span data-toggle="tooltip" data-placement="bottom">
                                <input type="text" id="real_name" value="<?=$model->real_name ?>" required/></span></td>
                    </tr>
                </table>
            </div>
            <div class="modal-footer">
             <button type="submit" class="btn btn-primary" id="save">保存</button>
            </div>
          
        </div>
    </div>
</div>
        
</div>



<?php
AppAsset::addCss($this,'/jQuery_File_Upload/css/jquery.fileupload.css');
AppAsset::addScript($this,'/jQuery_File_Upload/js/vendor/jquery.ui.widget.js');
AppAsset::addScript($this,'/jQuery_File_Upload/js/jquery.iframe-transport.js');
AppAsset::addScript($this,'/jQuery_File_Upload/js/jquery.fileupload.js');
AppAsset::addScript($this,'/http://static.tianpinwang.com.cn/v1/js/layer/layer.js');
?>
<?php $this->beginBlock('view') ?>


    $('#save').click(function(){
    var user_id = $('#password').attr('user_id');
    var password = $('#password').val();
    var newpassword = $('#newpassword').val();
    var email = $('#email').val();
    var real_name = $('#real_name').val();
    if(password!=newpassword){
        layer.alert('密码不一致');
        }else{
        if(!password ==''){
        $.post('/user/resetpassword',{'password':password,'user_id':user_id,'email':email,'real_name':real_name},function(data){
          if(data =='1'){
           layer.msg('修改成功',{time:3000});
            window.location.reload();
        }else if(data=='2'){
          layer.alert('密码修改失败');
         }
        })
        }else{
        $('#password').css('border','1px solid red');
         $('#newpassword').css('border','1px solid red');
        }
    }
    })


<?php $this->endBlock() ?>
<?php $this->registerJs($this->blocks['view'], \yii\web\View::POS_END); ?>
